#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n, m, x; cin >> n >> m >> x;
    vector<int> a(n), b(m);
    for(auto& e : a) cin >> e;
    for(auto& e : b) cin >> e;
    
    for(int i = 0, j = m - 1; i < n; ++i)
    {
        while(a[i] + b[j] > x && j > 0) --j;
        if(a[i] + b[j] == x)
        {
            cout << i << ' ' << j;
            break;
        }
    }
    return 0;
}